package com.shaoshaohuo.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RatingBar;
import android.widget.TextView;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.entity.Evaluation;
import com.shaoshaohuo.app.utils.StringHelper;

import java.util.List;

/**
 * 供应详情  底部简单 评论显示
 *
 * Created by cao on 2016/3/23.
 */
public class EvaluationSimpleAdapter extends MyBaseAdapter<Evaluation> {

    public EvaluationSimpleAdapter(Context ctx, List<Evaluation> list, boolean flag) {
        super(ctx, list, flag);
    }


    @Override
    public View getView(int pos, View convertView, ViewGroup group) {
        View view = View.inflate(context, R.layout.item_comment_simple_list_view, null);
        RatingBar ratingbar = (RatingBar) view.findViewById(R.id.ratingbar);
        TextView tv_name = (TextView) view.findViewById(R.id.tv_name);
        TextView tv_comment_text = (TextView) view.findViewById(R.id.tv_comment_text);
        TextView tv_date = (TextView) view.findViewById(R.id.tv_date);

        Evaluation evaluation = list.get(pos);
        ratingbar.setRating(Float.parseFloat(evaluation.getStartnum()));
        tv_name.setText(evaluation.getRealname().substring(0, 1) + "**");
        tv_comment_text.setText(evaluation.getContent());
        tv_date.setText(StringHelper.formatDateDay(evaluation.getCursor()));
        return view;
    }
}
